package com.bsh.controller.hotel;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.bsh.dto.HOrderListQryDto;
import com.bsh.service.HOrderService;
import com.bsh.service.HotelService;
import com.bsh.service.ModuleService;
import com.bsh.utils.Pager;

/**
 * @author jane
 * @since 0.0.1
 * 
 */
@Controller
public class OrderListController {
	private static Logger log = LoggerFactory.getLogger(OrderListController.class);
	@Autowired
	HttpServletRequest request;
	@Autowired
	HttpServletResponse response;
	@Autowired
	HttpSession session;
	@Autowired
	ModuleService module;
	@Autowired
	HOrderService orderService;
	@Autowired
	HotelService hotelService;

	/**
	 * 酒店订单列表
	 */
	@RequestMapping(value = "/hotel/order/list")
	public ModelAndView orderList(@ModelAttribute HOrderListQryDto dto) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/pages/hotel/orderList");
		
		String pageStr = request.getParameter("pageIndex");
		Integer pageIndex = Integer.parseInt(StringUtils.isEmpty(pageStr) ? "1" : pageStr);

		String sizeStr = request.getParameter("pageSize");
		Integer pageSize = Integer.parseInt(StringUtils.isEmpty(sizeStr) ? "20" : sizeStr);

		Pager pager = new Pager(pageIndex, pageSize);
		List<Map<String, Object>> list = orderService.getPage(pager, dto);
		mv.addObject("hotels",hotelService.getAll());
		mv.addObject("list", list);
		mv.addObject("pager", pager);
		mv.addObject("dto", dto);

		return mv;
	}

	
}
